#include "../header.h"

int main(int argc, char const *argv[])
{
    int sid = socket(AF_INET, SOCK_DGRAM, 0);
    printf("socket id: %d\n", sid);
    int value = 0;
    int size = sizeof(value);
    if(getsockopt(sid, SOL_SOCKET, SO_BROADCAST, &value, (socklen_t*)&size) < 0)
    {
        perror("getsoket error\n");
        return -1;
    }
    printf("获取广播成功,默认广播属性%d\n", value);
    value = 1;
    if(setsockopt(sid, SOL_SOCKET, SO_BROADCAST, &value, sizeof(value)) < 0)
    {
        perror("setsockopt error\n"); 
        return -2;
    }
    printf("设置广播成功\n");
    if(getsockopt(sid, SOL_SOCKET, SO_BROADCAST, &value, (socklen_t*)&size) < 0)
    {
        perror("getsoket error\n");
        return -1;
    }
    printf("再次获取广播成功,默认广播属性%d\n", value);
    close(sid);
    return 0;
}
